<!--步骤条组件-->
<template>
    <div>
        <div class="steps-box">
            <div
                v-for="(item, index) in stepsData"
                class="steps-card"
                :class="index <= stepsIndex ? 'on' : ''"
                :key="index">
<!--                下标+1-->
                <span>{{ index + 1 }}</span>
                <span>{{ item.name }}</span>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "Steps",
        data: function () {
            return {
                stepsIndex: "",
                stepsData: [],
            };
        },
        // 页面加载时
        created() {
            this.stepsIndex = this.$parent.stepsIndex;
            this.stepsData = this.$parent.stepsData;
        },
        methods: {
            //下一步
            stepsFun() {
                this.stepsIndex = this.$parent.stepsIndex;
            },
        },
    }
</script>

<style scoped>
    /*    steps-box*/
    .steps-box {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 30px;
        margin-top: 150px;
    }
    .steps-card {
        width: 300px;
        cursor: pointer;
        display: flex;
        align-items: center;
        color: rgba(0, 0, 0, 0.25);
        position: relative;
    }
    span:nth-of-type(1) {
        display: inline-block;
        width: 26px;
        height: 26px;
        text-align: center;
        line-height: 26px;
        border: 1px solid rgba(0, 0, 0, 0.15);
        border-radius: 50%;
        margin-right: 10px;
    }

    i {
        font-style: normal;
    }
    .steps-card:before {
        width: 194px;
        height: 1px;
        content: "";
        background: #e9e9e9;
        margin: 0 15px;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 0;
    }
    .steps-card:last-of-type {
        width: auto;
    }
    .steps-card:last-of-type:before {
        width: 0;
    }
    .steps-card.on {
        display: flex;
        align-items: center;
        color: rgba(0, 0, 0, 0.85);
    }

    span:nth-of-type(1) {
        display: inline-block;
        width: 26px;
        height: 26px;
        text-align: center;
        line-height: 26px;
        background: #1d73f6;
        border: 1px solid #1d73f6;
        color: #fff;
        border-radius: 50%;
        margin-right: 10px;
    }
    .steps-card.on:before {
        background: #1d73f6;
    }
</style>
